package com.salt.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.salt.entity.IdleAffiliateCpsIncomeDetail;
import com.salt.mapper.IdleAffiliateCpsIncomeDetailMapper;
import com.salt.service.IdleAffiliateCpsIncomeDetailService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.Map;

/**
 * 闲鱼联盟CPS佣金明细服务实现类
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class IdleAffiliateCpsIncomeDetailServiceImpl implements IdleAffiliateCpsIncomeDetailService {

    private final IdleAffiliateCpsIncomeDetailMapper incomeDetailMapper;

    @Override
    public Map<String, Object> getIncomeSummary(Date startDate, Date endDate, String inviteCode) {
        log.info("查询佣金明细汇总数据，开始日期：{}，结束日期：{}", startDate, endDate);
        return incomeDetailMapper.getIncomeSummary(startDate, endDate,inviteCode);
    }

    @Override
    public IPage<IdleAffiliateCpsIncomeDetail> pageQuery(
            Page<IdleAffiliateCpsIncomeDetail> page,
            Date startDate,
            Date endDate,
            Integer billState,
            Integer orderState,
            Boolean hasCoupon,
            String keyword, String inviteCode) {
        
        log.info("分页查询佣金明细数据，页码：{}，每页大小：{}，开始日期：{}，结束日期：{}，账单状态：{}，订单状态：{}，是否有优惠券：{}，关键词：{}",
                page.getCurrent(), page.getSize(), startDate, endDate, billState, orderState, hasCoupon, keyword);
        
        return incomeDetailMapper.pageQuery(page, startDate, endDate, billState, orderState, hasCoupon, keyword,inviteCode);
    }
} 